﻿@inherits BaseComponent

@if (Visible && Config.App.Type == AppType.Web)
{
    <div style="position:fixed;top:10px;right:10px;">
        <div id="btnPwaInstall" class="ant-btn ant-btn-default" style="display:block;width:110px;" onclick="addToDesktop()">@Language[Language.AddDesktop]</div>
        <div id="iosInstallGuide" style="display:none;">
            <p>@Language[Language.ClickShareButton] <KIcon Icon="share-alt" />@Language[Language.SelectInstallDesktop]</p>
        </div>
    </div>

    <script>
        const installButton = document.getElementById('btnPwaInstall');
        const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
        if ('serviceWorker' in navigator && 'onbeforeinstallprompt' in window) {
            if (isIOS || !('onbeforeinstallprompt' in window)) {
                installButton.style.display = 'none';
                document.getElementById('iosInstallGuide').style.display = 'block';
            }
        }
        window.addEventListener('load', () => {
            if (window.matchMedia('(display-mode: standalone)').matches) {
                installButton.style.display = 'none';
            }
        });
    </script>
}